/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.geom.Rectangle2D;
import javax.swing.JButton;
import net.worlds.ui.edge.EDGESettings;


public class CustomButton extends JButton{
    Color bgColor = new Color(123, 128, 154);
    Color hoverColor = new Color(197, 203, 217);
    Color borderColor = new Color(28, 36, 78);
    @Override
    public void paintComponent(Graphics g)
    {
        g.setFont(EDGESettings.defaultFont);
        if(getModel().isRollover() && !getModel().isPressed())
            g.setColor(hoverColor);
        else
            g.setColor(bgColor);
        Point l = getLocationOnScreen();
        g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(borderColor);
        g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        g.setFont(EDGESettings.defaultFont);
        Rectangle2D bounds = g.getFontMetrics().getStringBounds(getText(), g);
        int tx = (int) (getWidth()/2 - bounds.getWidth()/2);
        int ty = (int) (getHeight()/2 + bounds.getHeight()/2);
        g.drawString(getText(), tx, ty);
    }
}
